﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;

public partial class admin_adminChk : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!Page.IsPostBack)
        {
            check();
        }
    }
    //检测用户名是否已存在
    public void check() {
        if (Request["admin"] != null ) {
            OleDbConnection conn = DB.conn();
            if (conn != null) {
                OleDbCommand comm = null;
                try {
                    conn.Open();
                    comm = new OleDbCommand();
                    comm.Connection = conn;
                    comm.CommandText = "select * from admin where admin='"+Request["admin"].ToString().Trim()+"'";
                    OleDbDataReader reader = comm.ExecuteReader();
                    if (reader != null && reader.HasRows) {
                        Response.Write("此用户名已存在");
                    }
                }
                catch (Exception error)
                {
                    Response.Write(error.ToString());
                }
                finally {
                    if (comm != null) {
                        comm.Dispose();
                    }
                    conn.Close();
                }
            }
        }
    }
}
